<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

</head>
<body>
<ul id="lis">
    <li>我是第1个li标签</li>
    <li>我是第2个li标签</li>
    <li>我是第3个li标签</li>
    <li>我是第4个li标签</li>
    <li>我是第5个li标签</li>
    <li>我是第6个li标签</li>
    <li>我是第7个li标签</li>
    <li>我是第8个li标签</li>
</ul>
</body>
<script>
    var lis = document.getElementById('lis');
    var lis_li = lis.getElementsByTagName('li');
    for (var i =0; i < lis_li.length; i++) {

        if (i % 2 == 0) {

            lis_li[i].style.backgroundColor = 'skyblue';

        } else {
            lis_li[i].style.backgroundColor = 'pink';
        }
    }
    var ColorNew;
    for (var i =0; i < lis_li.length; i++) {
        lis_li[i].onmouseover = function () {
            ColorNew = this.style.backgroundColor;
            this.style.backgroundColor = 'red';

            //console.log(ColorNew);
        }
    }
    for (var i =0; i < lis_li.length; i++) {
        lis_li[i].onmouseout = function () {

            this.style.backgroundColor = ColorNew;

            //console.log(ColorNew);
        }
    }







</script>
</html>